<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <input type="text" id="getId">
    <button onclick="clickMe()">阶乘</button>
    <span id="resultId">结果</span>
    <script>
      function clickMe(){
        var num = document.getElementById("getId").value;
        if(num <=0){
          
        }
        for (let i = num - 1; i >= 2; i--) {
          num *=i;
        }
        var factorialObj = document.getElementById("resultId");
        factorialObj.innerHTML = "=" + num;
      }
    </script>

</body>
</html>